package com.sqx.modules.datacentre.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.service.UserMoneyService;
import com.sqx.modules.coupon.entity.TbCouponUser;
import com.sqx.modules.coupon.service.TbCouponService;
import com.sqx.modules.coupon.service.TbCouponUserService;
import com.sqx.modules.datacentre.service.DataCentreService;
import com.sqx.modules.errand.service.ErrandComplaintService;
import com.sqx.modules.integral.dao.UserIntegralDetailsDao;
import com.sqx.modules.integral.service.UserIntegralDetailsService;
import com.sqx.modules.order.service.AppOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@Api(value = "数据中心-管理端", tags = {"数据中心-管理端"})
@RequestMapping(value = "/admin/dataCentre")
public class DataCentreController {

    @Autowired
    private DataCentreService dataCentreService;
    @Autowired
    private AppOrderService appOrderService;
    @Autowired
    private TbCouponUserService tbCouponUserService;
    @Autowired
    private UserIntegralDetailsService userIntegralDetailsService;
    @Autowired
    private UserMoneyService userMoneyService;
    @Autowired
    private ErrandComplaintService errandComplaintService;

    @ApiOperation("数据中心")
    @GetMapping(value = "/dataCentre")
    public Result dataCentre() {
        return dataCentreService.dataCentre();
    }

    @ApiOperation("任务分析")
    @GetMapping(value = "selectOrderData")
    public Result selectOrderData(String date, String dateType) {
        return dataCentreService.selectOrderData(date, dateType);
    }

    @ApiOperation("任务详情分析")
    @GetMapping(value = "/selectOrderAnalyze")
    public Result selectPayOrderAnalyze(Integer page, Integer limit, String date, String dateType) {
        return dataCentreService.selectPayOrderAnalyze(page, limit, date, dateType);
    }

    @ApiOperation("条件筛选所有用户")
    @GetMapping(value = "selectAllUser")
    public Result selectAllUser(Integer page, Integer limit, String userName, String phone) {
        return dataCentreService.selectAllUser(page, limit, userName, phone);
    }

    @ApiOperation("根据userId查询")
    @GetMapping(value = "selectUserById")
    public Result selectUserById(Long userId) {
        return dataCentreService.selectUserById(userId);
    }

    @ApiOperation("给用户账户修改余额")
    @GetMapping(value = "addUserMoney")
    public Result addUserMoney(Long userId, BigDecimal money, Integer type) {
        return userMoneyService.addUserMoney(userId, money, type);
    }

    @ApiOperation("修改用户保证金")
    @GetMapping(value = "updateCashDeposit")
    public Result updateCashDeposit(Long userId, BigDecimal money, Integer type) {
        return userMoneyService.updateCashDeposit(userId, money, type);
    }

    @ApiOperation("给骑手修改余额")
    @GetMapping(value = "updateUserBalance")
    public Result updateUserBalance(Long userId, BigDecimal money, Integer type) {
        return userMoneyService.updateUserBalance(userId, money, type);
    }


    @ApiOperation("查看该用户下单信息(下单数、下单金额)")
    @GetMapping(value = "selectOrderByUserId")
    public Result selectOrderByUserId(Long userId, String date, String dateType) {

        return appOrderService.selectOrderByUserId(userId, date, dateType);
    }

    @ApiOperation("查看该用户下单详情")
    @GetMapping(value = "selectOrderDetails")
    public Result selectOrderDetails(Integer page, Integer limit, Long userId) {

        return appOrderService.selectOrderDetails(page, limit, userId);
    }

    @ApiOperation("查看用户拥有的优惠券")
    @GetMapping(value = "selectCouponByUserId")
    public Result selectCouponByUserId(Integer page, Integer limit, Long userId, Integer status, String phone) {

        return tbCouponUserService.selectCouponByUserId(page, limit, userId, status, phone);
    }

    @ApiOperation("查看积分明细")
    @GetMapping(value = "/selectSignIn")
    public Result selectSignIn(Integer page, Integer limit, Long userId) {

        return userIntegralDetailsService.selectSignIn(page, limit, userId);
    }

    @ApiOperation("财务中心-充值统计")
    @GetMapping(value = "selectTopUpStatistics")
    public Result selectTopUpStatistics(String date, String dateType) {

        return dataCentreService.selectTopUpStatistics(date, dateType);
    }

    @ApiOperation("查看所有实名认证待审核用户")
    @GetMapping(value = "findAllCertification")
    public Result findAllCertification(Integer page, Integer limit, String userName, String phone, String checkCertification) {
        return dataCentreService.findAllCertification(page, limit, userName, phone, checkCertification);
    }

    @ApiOperation("实名认证审核")
    @PostMapping("checkCertification")
    public Result checkCertification(Long userId, String checkCertification, String checkCertificationMessage) {

        return dataCentreService.checkCertification(userId, checkCertification, checkCertificationMessage);
    }

    @ApiOperation("查看用户实名认证信息")
    @GetMapping(value = "findCertification")
    public Result findCertification(Long userId) {

        return dataCentreService.findCertification(userId);
    }

    @ApiOperation("接单排行榜")
    @GetMapping(value = "rankingList")
    public Result rankingList(Integer page, Integer limit, String address, String date, String dateType) {

        return dataCentreService.rankingList(page, limit, address, date, dateType);
    }

    @ApiOperation("门店统计")
    @GetMapping(value = "selectShopCenter")
    public Result selectShopCenter(String date, String dateType, Integer page, Integer limit) {

        return dataCentreService.selectShopCenter(date, dateType, page, limit);
    }

    @ApiOperation("用户统计")
    @GetMapping(value = "selectUserCenter")
    public Result selectUserCenter(String date, String dateType) {

        return dataCentreService.selectUserCenter(date, dateType);
    }

    @GetMapping(value = "selectUserFeedback")
    @ApiOperation("查看意见反馈")
    public Result selectUserFeedback(String userEmail, Integer page, Integer limit) {

        return dataCentreService.selectUserFeedback(userEmail, page, limit);
    }

    @ApiOperation("获取该用户所有派单任务")
    @GetMapping(value = "findUserAddIndent")
    public Result findUserAddIndent(Long userId, Integer page, Integer limit) {

        return dataCentreService.findUserAddIndent(userId, page, limit);
    }

    @ApiOperation("获取该用户所有接单任务")
    @GetMapping(value = "findUserReceivingIndent")
    public Result findUserReceivingIndent(Long userId, Integer page, Integer limit) {

        return dataCentreService.findUserReceivingIndent(userId, page, limit);
    }

    @ApiOperation("查看充值明细")
    @GetMapping(value = "findTopUpMoney")
    public Result findTopUpMoney(Long userId, Integer page, Integer limit, String startTime, String endTime) {

        return dataCentreService.findTopUpMoney(userId, page, limit, startTime, endTime);
    }


    @ApiOperation("查看提现记录")
    @GetMapping(value = "findWithdrawMoney")
    public Result findWithdrawMoney(Long userId, Integer page, Integer limit) {

        return dataCentreService.findWithdrawMoney(userId, page, limit);
    }

    //查看全部骑手申诉（条件查询）
    @ApiOperation("查看全部骑手申诉")
    @GetMapping(value = "findAllAppeal")
    public Result findAllAppeal(Integer page, Integer limit, Long userId, Integer illegalId, Integer complaintState, String indentNumber) {

        return errandComplaintService.findAllAppeal(page, limit, userId, illegalId, complaintState, indentNumber);
    }

    @ApiOperation("同城跑腿收入统计")
    @GetMapping(value = "findplatformMoney")
    public Result findplatformMoney(String dateType, String date) {

        return dataCentreService.findplatformMoney(dateType, date);
    }

    @ApiOperation("外卖点餐收入统计")
    @GetMapping(value = "tcwmplatformMoney")
    private Result tcwmplatformMoney(String date, String dateType) {

        return dataCentreService.tcwmplatformMoney(date, dateType);
    }


    @ApiOperation("保证金管理")
    @GetMapping(value = "selectCashDeposit")
    public Result selectCashDeposit(String phone, Integer type, Integer page, Integer limit, Long userId) {

        return dataCentreService.selectCashDeposit(phone, type, page, limit, userId);
    }

   /* @ApiOperation("用户中心 用户列表")
    @GetMapping(value = "findAllUser")
    public Result findAllUser(Integer page, Integer limit, String phone, Integer userType, String platform, String nickName, String invitationCode){

        return dataCentreService.findAllUser(page, limit, phone, userType, platform, nickName, invitationCode);
    }*/

    @ApiOperation("查看反馈列表")
    @GetMapping(value = "selectFeedbackList")
    public Result selectFeedbackList(Integer page, Integer limit, Integer feedbackType) {

        return dataCentreService.selectFeedbackList(page, limit, feedbackType);
    }

    /*==========================================================*/

    @ApiOperation("管理端赠送用户会员")
    @PostMapping(value = "presenterVip")
    public Result presenterVip(Long userId) {

        return dataCentreService.presenterVip(userId);
    }


}
